<?php echo form_open('/' . $this->curl . '/index/', 'id="myform" name="myform"')?>

<table width="100%" border="0" cellpadding="3" cellspacing="0" id="grid" class="display">
<thead>
<tr>
	<th class="first"><?php echo form_checkbox('cid_toggle', null, FALSE, 'id="cid_toggle" onclick="toggleCheckboxes($(this))"')?></th>
	<th><?php echo $this->account_resource_model->fields['category'] ?></th>
	<th><?php echo $this->account_resource_model->fields['controller'] ?></th>
	<th><?php echo $this->account_resource_model->fields['action'] ?></th>
	<th><?php echo $this->account_resource_model->fields['description'] ?></th>
	<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach ($list as $row): ?>
<tr id="tr_<?php echo $row->id?>">
	<td class="t-center"><?php echo form_checkbox('cid[]', $row->id, FALSE, 'class="checkbox" id="cb'. $row->id.'"')?></td>
	<td><?php echo $row->category?></td>
	<td><?php echo $row->controller?></td>
	<td><?php echo $row->action?></td>
	<td><?php echo $row->description?></td>
	<td width="26" class="t-center"><?php echo anchor($this->curl.'/edit_resource/'.$row->id, ' ', 'class="btn_edit" alt="'.T_('Edit').'" title="'.T_('Edit').'"')?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
	
<?php echo form_close()?>

<script type="text/javascript">
var oTable;

$(document).ready(function() {
	
	/* Add a click handler to the rows - this could be used as a callback */
	$('#grid tr').click( function() {
		if ( $(this).hasClass('row_selected') )
		{			
			$(this).removeClass('row_selected');
			$(this).find('.checkbox').removeAttr('checked');
		}			
		else
		{
			$(this).addClass('row_selected');
			$(this).find('.checkbox').attr('checked', 'checked');
		}			
	});
		
	/* Init DataTables */
	oTable = $('#grid').dataTable(
	{
		"oLanguage": {
		"sLengthMenu": "Показывать _MENU_ записей на стр.",
		"sZeroRecords": "Нет данных.",
		"sInfo": "От _START_ до _END_ из _TOTAL_ записей",
		"sInfoEmpty": "0 записей",
		"sInfoFiltered": "(filtered from _MAX_ total records)",
		"sSearch": "Искать",
		"oPaginate": {
			"sFirst": "Первая",
			"sLast": "Последняя",
			"sNext": "Вперед",
			"sPrevious": "Back"
			}
		},
		
		"aaSorting": [[ 2, "asc" ]],				
		"aoColumns": [
  			{ "bSortable": false },
  			null,
  			null,
  			null,
  			null,  			  			
  			{ "bSortable": false }
		],
																	
		"bPaginate": true,
		"bLengthChange": true,
		"bFilter": true,	
		"bSort": true,
		"bInfo": true,
		"bAutoWidth": true,
		"bJQueryUI": true,
		"sPaginationType": "full_numbers"	
	});
});	

/*
 * I don't actually use this here, but it is provided as it might be useful and demonstrates
 * getting the TR nodes from DataTables
 */
function fnGetSelected( oTableLocal )
{
	var aReturn = new Array();
	var aTrs = oTableLocal.fnGetNodes();
	
	for ( var i=0 ; i<aTrs.length ; i++ )
	{
		if ( $(aTrs[i]).hasClass('row_selected') )
		{
			aReturn.push( aTrs[i] );
		}
	}
	return aReturn;
}
</script>